package Day5Zuoye;

import java.io.*;

public class Test7 {
    public static void main(String[] args) {
        BufferedReader br=null;
        BufferedWriter bw=null;
        try {
            FileInputStream fis=new FileInputStream("C:\\Users\\Administrator\\Desktop\\xinjian\\wuliu. template");
            br=new BufferedReader(new InputStreamReader(fis,"utf-8"));
            String str=null;
            StringBuffer sbf=new StringBuffer();
            while ((str=br.readLine())!=null){
                sbf.append(str);
            }
            System.out.println("替换前:"+sbf);
            String newString="",newString1="",newString2="";
            newString=sbf.toString().replace("{danhao}","10010");
            newString1=sbf.toString().replace("{weizhi}","合肥物流中心");
            newString2=sbf.toString().replace("{tiquma}","340121");
            String newString3=newString+newString1+newString2;
            System.out.println("替换后:"+newString3);
            bw=new BufferedWriter(new FileWriter("C:\\Users\\Administrator\\Desktop\\xinjian\\wuliu.txt"));
            bw.write(newString3);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
